package niumao.minecraft.uhc.listener;

import niumao.minecraft.uhc.Main;
import niumao.minecraft.uhc.Util;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;

public class hermes implements Listener {
    @EventHandler
    public void on(PlayerJoinEvent event) {
        event.getPlayer().setWalkSpeed(0.2f);
    }

    public static void runnablerunner() {
        new BukkitRunnable() {
            @Override
            public void run() {
                for (Player player : Bukkit.getServer().getOnlinePlayers()) {
                    ItemStack item = player.getInventory().getBoots();
                    if (item == null) {
                        if (player.getWalkSpeed() == 0.22f) {
                            player.setWalkSpeed(0.2f);
                        }
                        return;
                    } else if (item.getItemMeta().getDisplayName().equals(Util.getStr("Hermes"))) {
                        if (player.getWalkSpeed() == 0.2f) {
                            player.setWalkSpeed(0.22f);
                        }
                    }
                }
            }
        }.runTaskTimer(Main.getInstance(), 0L, 20L);
    }
}
